package com.fypg.module.medical.dal.mysql.department;

import java.util.*;

import com.fypg.framework.common.pojo.PageResult;
import com.fypg.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.fypg.framework.mybatis.core.mapper.BaseMapperX;
import com.fypg.module.medical.dal.dataobject.department.DepartmentDO;
import org.apache.ibatis.annotations.Mapper;
import com.fypg.module.medical.controller.admin.department.vo.*;

/**
 * 科室信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DepartmentMapper extends BaseMapperX<DepartmentDO> {

    default PageResult<DepartmentDO> selectPage(DepartmentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DepartmentDO>()
                .eqIfPresent(DepartmentDO::getHospitalId, reqVO.getHospitalId())
                .eqIfPresent(DepartmentDO::getEncode, reqVO.getEncode())
                .likeIfPresent(DepartmentDO::getDepartmentName, reqVO.getDepartmentName())
                .eqIfPresent(DepartmentDO::getMainId, reqVO.getMainId())
                .eqIfPresent(DepartmentDO::getParentId, reqVO.getParentId())
                .eqIfPresent(DepartmentDO::getClassList, reqVO.getClassList())
                .eqIfPresent(DepartmentDO::getClasslayer, reqVO.getClasslayer())
                .eqIfPresent(DepartmentDO::getAvatarUrl, reqVO.getAvatarUrl())
                .eqIfPresent(DepartmentDO::getLocation, reqVO.getLocation())
                .eqIfPresent(DepartmentDO::getIntroduction, reqVO.getIntroduction())
                .eqIfPresent(DepartmentDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(DepartmentDO::getExtendData, reqVO.getExtendData())
                .eqIfPresent(DepartmentDO::getSortCode, reqVO.getSortCode())
                .eqIfPresent(DepartmentDO::getEnabledMark, reqVO.getEnabledMark())
                .eqIfPresent(DepartmentDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(DepartmentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DepartmentDO::getId));
    }

}